﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using TF.Access;
using System.IO;
using System.Drawing;

public partial class TFAlbumNew : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
        {
            string script = string.Empty;
            Tf_pic pic = HttpContext.Current.Session["userPic"] as Tf_pic;
            if (pic != null)
            {
                string picUrl = string.Empty;
                int ret = WebUtility.UploadPhoto("UploadURL", pic.Album_name, out picUrl);
                if (ret < 0)
                {
                    pic.Pic_url = picUrl;
                    pic.Update();
                    script = WebUtility.Alert("添加成功");
                }
                else
                {
                    if (ret == 0)
                    {
                        script = WebUtility.Alert("上传文件不是有效的图片文件");
                    }
                    else if (ret == 1)
                    {
                        script = WebUtility.Alert("请指定一个有效的文件");
                    }
                    else if (ret == 2)
                    {
                        script = WebUtility.Alert("添加失败");
                    }
                    else if (ret == 3)
                    {
                        script = WebUtility.Alert("上传图片不能超过4M");
                    }
                    pic.Delete();
                }
            }

            ClientScript.RegisterStartupScript(this.GetType(), "uploadNotify", script);
        }
    }
}
